/**
 * 这是一个单独的 reducer
 */

const initialState = 0;

/**
 * 该函数默认会被 redux 触发几次
 *     传递过来的 action.type 都是一些 @@xxxx 随机值
 */
export default (state = initialState, action: any) => {
  console.log("counter-reducer", state, action);
  switch (action.type) {
    case "counter/increment":
      return state + 1;
    case "counter/decrement":
      return state - 1;
    default:
      return state;
  }
};
